package com.mini.repository;

import com.mini.model.BusinessChancePhoneRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author shixiaopeng  on 2020/12/2
 */
@Repository
public interface BusinessChancePhoneRecordRepository extends JpaRepository<BusinessChancePhoneRecord, Long>, JpaSpecificationExecutor<BusinessChancePhoneRecord> {

    List<BusinessChancePhoneRecord> findByPhone(String phone);

    @Query(value = "select * from business_chance_phone_record where phone = ?1 and to_days(create_time) = to_days(now()) limit 1;", nativeQuery = true)
    BusinessChancePhoneRecord findTodayByPhone(String phone);
}
